package com.ihr360.payroll.dao;

import com.ihr360.payroll.model.dto.salary.plan.config.PayslipConfig;
import com.ihr360.rest.reposity.SimpleRestReposity;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;

import java.util.List;

/**
 * @author tomtao
 */
@RepositoryRestResource
public interface PayslipConfigRepository extends SimpleRestReposity<PayslipConfig, Long> {
    /**
     * 删除工资单关联的字段
     *
     * @param fieldIds
     * @return
     */
    @Modifying
    @Query(nativeQuery = true, value = "delete from payslipconfig_fields where fields_id in (:fieldIds)")
    Integer deletePayslipConfigFieldsByFieldId(@Param("fieldIds") List<Long> fieldIds);

    long countByCompanyIdAndIdNotAndName(String companyId, Long id, String name);

    long countByCompanyIdAndName(String companyId, String name);

}
